package com.example.controller;

import com.example.entity.Statistics;
import com.example.service.StatisticsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/statistics")
public class StatisticsController {
    
    @Autowired
    private StatisticsService statisticsService;

    @GetMapping
    public Result<Statistics> getStatistics() {
        return Result.success(statisticsService.getStatistics());
    }

    @PostMapping("/visit")
    public Result<Void> incrementVisitCount() {
        statisticsService.incrementVisitCount();
        return Result.success();
    }

    @PostMapping("/online/increment")
    public Result<Void> incrementOnlineCount() {
        statisticsService.incrementOnlineCount();
        return Result.success();
    }

    @PostMapping("/online/decrement")
    public Result<Void> decrementOnlineCount() {
        statisticsService.decrementOnlineCount();
        return Result.success();
    }
} 